package cn.lyh.FoodSystem.Controller;


import cn.lyh.FoodSystem.Dto.Result;
import cn.lyh.FoodSystem.Entity.Speed;
import cn.lyh.FoodSystem.Service.SpeedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



import static cn.lyh.utils.HutoolJWTUtil.parseToken;

@RestController
@RequestMapping("/speed")
public class SpeedController {
    @Autowired
    private SpeedService speedService;

    /**
     * 查询视频进度数据
     */
    @GetMapping("/querySpeed")
    public Result updateEntry(@RequestHeader("token") String token){
        Result result = new Result();
        try {
            return  speedService.querySpeed(String.valueOf(parseToken(token)));
        }catch (Exception e){
            result.setMsg("程序错误！");
            result.setCode(500);
            return result;
        }
    }


    /**
     * 更新数据
     */
    @PostMapping("/updateSpeed")
    public Result updateEntry(@RequestBody Speed speed){
        return speedService.updateSpeed(speed);
    }

    /**
     * 删除数据
     */
    @PostMapping("/deleteSpeed")
    public Result deleteEntry(@RequestBody Speed speed){
        return speedService.deleteSpeed(speed);
    }

}
